package br.com.edoc.entidade;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import javax.persistence.Table;

@Entity
@Table(name="PERFILUSUARIO")
public class Perfil implements EntidadePadrao{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8491318465727977987L;
	@Id  
	@Column(name = "PRU_IDDOOBJETO", nullable = false)  
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	@Column(name = "PRU_DESCRICAO", nullable = false, length=50)
	private String descricao;
	@Column(name = "PRU_OBS", nullable = false, length=50)
	private String obs;
	@ManyToOne (cascade={CascadeType.PERSIST})
	@JoinColumn(name="MOD_IDDOOBJETO")
	private Modulo modulo;
	@OneToMany(mappedBy="perfil",orphanRemoval=true,cascade={CascadeType.ALL})
	
	private List<PermissaoUsuario> listaPermissoes;
	@Override
	public Integer getId() {
		// TODO Auto-generated method stub
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getDescricao() {
		return descricao;
	}
	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}
	public String getObs() {
		return obs;
	}
	public void setObs(String obs) {
		this.obs = obs;
	}
	public List<PermissaoUsuario> getListaPermissoes() {
		if(listaPermissoes == null){
			listaPermissoes = new ArrayList<PermissaoUsuario>();
		}
		return listaPermissoes;
	}
	public void setListaPermissoes(List<PermissaoUsuario> listaPermissoes) {
		this.listaPermissoes = listaPermissoes;
	}
	public Modulo getModulo() {
		if(modulo == null){
			modulo = new Modulo();
		}
		return modulo;
	}
	public void setModulo(Modulo modulo) {
		this.modulo = modulo;
	}
	
	

}
